#pragma once
#include"NoFlagGraph.h"
#include"DirectGraph.h"
#include"WeightNoDirGraph.h"
#include"WeightDirGraph.h"

class GraphTest
{
public:
	GraphTest();

	void NoFlagGraphTest();
	void DirectGraphTest();

	void WeightNoDirGraphTest();
	void WeightDirGraphTest();
};

GraphTest::GraphTest() {
	//NoFlagGraphTest();
	//DirectGraphTest();
	//WeightNoDirGraphTest();
	WeightDirGraphTest();
}

void GraphTest::NoFlagGraphTest() {
	NoFlagGraph *ng = new NoFlagGraph(13);
	ng->AddEdige(0, 6);
	ng->AddEdige(0, 2);
	ng->AddEdige(0, 1);
	ng->AddEdige(0, 5);
	ng->AddEdige(6, 4);
	ng->AddEdige(4, 5);
	ng->AddEdige(4, 3);
	ng->AddEdige(3, 5);

	ng->AddEdige(7, 8);

	ng->AddEdige(9, 11);
	ng->AddEdige(9, 10);
	ng->AddEdige(9, 12);
	ng->AddEdige(11, 12);

	//ng->DeepFirstFind(9);

	//ng->BreadthFirstSearch(0);
	ng->pathTo(0, 3);
}


void GraphTest::DirectGraphTest() {
	DirectGraph *dg = new DirectGraph(6);
	dg->AddEdige(0, 2);
	dg->AddEdige(0, 3);
	dg->AddEdige(1, 3);
	dg->AddEdige(2, 4);
	dg->AddEdige(3, 4);
	dg->AddEdige(4, 5);

	
	dg->topSort();
	dg->printTopResault();

	printf("%d\n", dg->HasCycle());

	dg->AddEdige(4, 0);
	printf("%d\n", dg->HasCycle());
}


void GraphTest::WeightDirGraphTest() {
	WeightDirGraph *wg = new WeightDirGraph(8);
	Edige* e0 = new Edige(4, 5, 0.35);
	Edige* e1 = new Edige(4, 7, 0.37);
	Edige* e2 = new Edige(5, 7, 0.28);
	Edige* e3 = new Edige(0, 7, 0.16);
	Edige* e4 = new Edige(1, 5, 0.32);
	Edige* e5 = new Edige(0, 4, 0.38);
	Edige* e6 = new Edige(2, 3, 0.17);
	Edige* e7 = new Edige(1, 7, 0.19);
	Edige* e8 = new Edige(0, 2, 0.26);
	Edige* e9 = new Edige(1, 2, 0.36);
	Edige* e10 = new Edige(1, 3, 0.29);
	Edige* e11 = new Edige(2, 7, 0.34);
	Edige* e12 = new Edige(6, 2, 0.40);
	Edige* e13 = new Edige(3, 6, 0.52);
	Edige* e14 = new Edige(6, 0, 0.58);
	Edige* e15 = new Edige(6, 4, 0.93);

	wg->AddEdige(e0);
	wg->AddEdige(e1);
	wg->AddEdige(e2);
	wg->AddEdige(e3);
	wg->AddEdige(e4);
	wg->AddEdige(e5);
	wg->AddEdige(e6);
	wg->AddEdige(e7);
	wg->AddEdige(e8);
	wg->AddEdige(e9);
	wg->AddEdige(e10);
	wg->AddEdige(e11);
	wg->AddEdige(e12);
	wg->AddEdige(e13);
	wg->AddEdige(e14);
	wg->AddEdige(e15);

	wg->pathTo(0,6);

}


void GraphTest::WeightNoDirGraphTest() {
	WeightNoDirGraph *wg = new WeightNoDirGraph(8);
	Edige* e0 = new Edige(4, 5, 0.35);
	Edige* e1 = new Edige(4, 7, 0.37);
	Edige* e2 = new Edige(5, 7, 0.28);
	Edige* e3 = new Edige(0, 7, 0.16);
	Edige* e4 = new Edige(1, 5, 0.32);
	Edige* e5 = new Edige(0, 4, 0.38);
	Edige* e6 = new Edige(2, 3, 0.17);
	Edige* e7 = new Edige(1, 7, 0.19);
	Edige* e8 = new Edige(0, 2, 0.26);
	Edige* e9 = new Edige(1, 2, 0.36);
	Edige* e10 = new Edige(1, 3, 0.29);
	Edige* e11 = new Edige(2, 7, 0.34);
	Edige* e12 = new Edige(6, 2, 0.40);
	Edige* e13 = new Edige(3, 6, 0.52);
	Edige* e14 = new Edige(6, 0, 0.58);
	Edige* e15 = new Edige(6, 4, 0.93);

	wg->AddEdige(e0);
	wg->AddEdige(e1);
	wg->AddEdige(e2);
	wg->AddEdige(e3);
	wg->AddEdige(e4);
	wg->AddEdige(e5);
	wg->AddEdige(e6);
	wg->AddEdige(e7);
	wg->AddEdige(e8);
	wg->AddEdige(e9);
	wg->AddEdige(e10);
	wg->AddEdige(e11);
	wg->AddEdige(e12);
	wg->AddEdige(e13);
	wg->AddEdige(e14);
	wg->AddEdige(e15);

	wg->PrimMST();

	wg->KruskalMST();
}